﻿@Cofe ?= {}

$ = jQuery
Entry = Cofe.Entry
utils = Cofe.utils

# CONTROLLER - Represents one entry.
#     params - @el, @templateKey (css template) , @entry (entry model), @App (for calling methods like changePath())
#     events - clicked
class EntryItem extends Spine.Controller
  constructor : (dic) ->                   # Overridable parameters.            
    super        
  tag : "li"
  
  elements :
    ".workIndicator" : "workIndicator"
    ".label" : "label"

  events :
    "click .changePath" : "click"
    
  init: ->     

  render: (templateKey) =>     
    @el.html(@template(templateKey))      
  
  remove: =>
    @el.remove()

  template: (templateKey) ->
    if templateKey is undefined then throw "templateKey not specified"
    templateKey.render(@entry)
  
  click: ->
    #console.log "clicked" + @entry.path
    @trigger("clicked", @)
   
   
Cofe.EntryItem = EntryItem